//
//  BaseResquestModel.m
//  Timingbar
//
//  Created by zibin on 2017/7/17.
//  Copyright © 2017年 timingbar. All rights reserved.
//

#import "BaseResquestModel.h"

@implementation BaseResquestModel
- (NSString *)url
{
    return @"";
}
- (NSDictionary *)modelToBaseResquestModel
{
    NSDictionary *keyValueDict = [self modelToDictionary];
    NSMutableDictionary *processKeyValueDict = [keyValueDict mutableCopy];
    if([self respondsToSelector:@selector(replaceOldPropertyNameToNewPropertyName)]){
        NSDictionary *replaceDict = [self replaceOldPropertyNameToNewPropertyName];
        if(replaceDict.allKeys.count != 0){
            [replaceDict enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
                if([processKeyValueDict.allKeys containsObject:key]){
                    id  value = [processKeyValueDict valueForKeyPath:key];
                    [processKeyValueDict removeObjectForKey:key];
                    [processKeyValueDict setValue:value forKey:obj];
                    
                }
            }];
        }
        
    }
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [processKeyValueDict enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        if([obj isKindOfClass:[NSNull class]] && [key isKindOfClass:[NSString class]])
        {
            obj = @"";
        }
        [dict setValue:obj forKey:key];
    }];
    return  dict;
}

- (NSDictionary *)replaceOldPropertyNameToNewPropertyName
{
    return nil;
}

@end
